import shutil
import os


file_path = r"I:\SaveData"
Camera_path = os.path.join(file_path, 'Camera', '2024-05-02')
Lidar_path = os.path.join(file_path, 'Lidar', '2024-05-02')
hour = "16"     # 保存一小时数据的时间
save_path = r"I:\saveDataCopy20240805" # 另存为的地址
for i in range(1, 13):
    if not os.path.exists(os.path.join(save_path, str(i), 'pcap')):
        os.makedirs(os.path.join(save_path, str(i), 'pcap'))

    if not os.path.exists(os.path.join(save_path, str(i), 'video')):
        os.makedirs(os.path.join(save_path, str(i), 'video'))

for root, dirs, files in os.walk(Camera_path):
    for file in files:
        date_str = file.split("_")[0]
        other_str = file.split("_")[1]
        time_str = other_str.split('-')[3]  # 获取小时数
        station_name = int(int(date_str) / 3) + 1
        if station_name == 1:
            # station_name = int(int(date_str) / 3) + 1
            source_file_path = os.path.join(root, file)
            destination_file_path = os.path.join(save_path, str(station_name), 'video')
            if os.path.exists(destination_file_path+"/"+file):
                print("目标存在",destination_file_path)
                continue
            print("相机",source_file_path, destination_file_path)
            shutil.copy(source_file_path, destination_file_path)

for root, dirs, files in os.walk(Lidar_path):
    for file in files:
        date_str = file.split("_")[0]
        other_str = file.split("_")[1]
        time_str = other_str.split('-')[3]  # 获取小时数
        station_name = int(date_str)
        if station_name == 1:
            station_name = int(date_str)
            source_file_path = os.path.join(root, file)
            destination_file_path = os.path.join(save_path, str(station_name), 'pcap')
            if os.path.exists(destination_file_path+"/"+file):
                print("目标存在",destination_file_path)
                continue
            print("点云",source_file_path, destination_file_path)
            shutil.copy(source_file_path, destination_file_path)
